package com.micro;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@SuppressWarnings("unchecked")
public class DWRTest {
 
/**
   * 第一个简单调用
   */
public String getStr() {
    return "第一个dwr示例，调用成功";
}
 
/**
   * 带传递参数的调用，返回String
   */
public String getInfo(String name, int age, String address) {
    return "我的名字叫" + name + ",现年" + age + "岁," + "来自" + address;
}
 
/**
   * 返回数组Array
   */
public String[] getStrArray() {
    return new String[] { "one", "two", "three", "go!" };
}
 
/**
   * 返回集合List
   */
public List getList() {
    List list = new ArrayList();
    list.add("welcome");
    list.add("to");
    list.add("BeiJing");
    return list;
}
 
/**
   * 返回Map类型
   */
public Map getMap() {
    Map map = new HashMap();
    map.put("name", "周星星");
    map.put("hobby", "逃课");
    return map;
}
 
/**
   * 返回二维数组类型
   */
public List getArrayList() {
    List list = new ArrayList();
    list.add(new String[] { "1", "2", "3" });
    list.add(new String[] { "one", "two", "three", "four", "five" });
    return list;
}
 
/**
   * Exception处理
   */
public List getListTest(List list) {
    try {
      list.get(0);
    } catch (Exception e) {
      throw new NullPointerException("数据位空");
    }
    return list;
}
 
}
